﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var conString = "server=.;database=User;uid=sa;pwd=123456";

            SqlConnection sqlconnection = new SqlConnection(conString);//函数调用//


            sqlconnection.Open();//打开数据库

           
            var sqlcommderstring = "select * from Student";//查询表

            SqlCommand command = new SqlCommand(sqlcommderstring, sqlconnection);//初始化一个命令对象，准备执行


            var reader = command.ExecuteReader();//从SQL表的第一行的上一行往后查询，看看查询结果是什么
            Console.WriteLine("{0}\t{1}\t{2}\t{3}", "ID", "Name", "Age", "ShengGao");
            while (reader.Read())
            {
                Console.WriteLine("{0}\t{1}\t{2}\t{3}",reader["ID"],reader["Name"], reader["Age"], reader["ShengGao"] );//打印表格

            }
            sqlconnection.Close();//关闭数据库


            //仅此一家，其它都是盗版！


        }
    }
}
